//
//@File    :	9.6_support.cpp
//@Time    :	2021/08/22 16:58:24
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	use external varible
//

#include <iostream>

using namespace std;

extern double warming;//使用外部定义的变量
void update(double dt);
void local();

void update(double dt)
{
    extern double warming;
    warming +=dt;
    cout<<"Updating global warming to "<<warming;
    cout<<" degrees.\n";
}

void local()
{
    double warming = 0.8;//局部变量掩盖全局变量
    cout<<"Local warming = "<<warming<<" degrees.\n";
    cout<<"But global warming = "<<::warming;//作用域解析符(::),表示使用变量的全局版本
    cout<<" degrees.\n";
}
